@isTest
private class TestDevBacController {
	static testMethod void testDevBac(){
		PageReference SchemaPage1 = new Pagereference('/apex/DevBac?');
		Test.setCurrentPage(SchemaPage1);
		DevBacController obj = new DevBacController();
		obj.InitApexTest();
		
		obj.checkForToken();
		System.debug('************'+obj.authToken);
		List<SelectOption> sfres = obj.getSFRes();
		obj.ResourceName = 'Classes';
		List<SelectOption> components = new List<SelectOption>();
		components.addAll(obj.getOptions());
		
		obj.ResourceName = 'Triggers';
		components.clear();
		components.addAll(obj.getOptions());
		
		obj.ResourceName = 'VFPages';
		components.clear();
		components.addAll(obj.getOptions());
		
		obj.ResourceName = 'SControls';
		components.clear();
		components.addAll(obj.getOptions());
		
		
		ApexClass[] cls = [select Id from ApexClass];
		List<String> classes = new List<String>();
		for(ApexClass apexCls: cls){
			classes.add(apexCls.Id);
		}
		obj.setSelectedResources(classes);
		classes.clear();
		classes.addAll(obj.getSelectedResources());
		
		obj.ResourceName = 'Classes';
		obj.Upload();
		
		ApexTrigger[] triggers = [select Id from ApexTrigger];
		List<String> tgrs = new List<String>();
		for(ApexTrigger tgr: triggers){
			tgrs.add(tgr.Id);
		}
		obj.setSelectedResources(tgrs);
		obj.ResourceName = 'Triggers';
		obj.Upload();
		
		ApexPage[] pages = [select Id from ApexPage];
		List<String> pgs = new List<String>();
		for(ApexPage pg: pages){
			pgs.add(pg.Id);
		}
		obj.setSelectedResources(pgs);
		obj.ResourceName = 'VFPages';
		obj.Upload();
		
		Scontrol[] scntrls = [select Id from Scontrol];
		List<String> scs = new List<String>();
		for(Scontrol sc: scntrls){
			scs.add(sc.Id);
		}
		obj.setSelectedResources(scs);
		obj.ResourceName = 'SControls';
		obj.Upload();
		
		obj.ResourceName = 'SControls';
		scs.clear();
		obj.setSelectedResources(scs);
		obj.Upload();
		
		User curUser = [Select GoogleDocsToken__c from User where Id=: UserInfo.getUserId()];
        curUser.GoogleDocsToken__c ='';
        update curUser;
		
		obj.checkForToken();
		System.debug('************'+obj.authToken);
		
		
		Scontrol[] scntrls1 = [select Id from Scontrol];
		for(Scontrol sc: scntrls1){
			scs.add(sc.Id);
		}
		obj.setSelectedResources(scs);
		obj.ResourceName = 'SControls';
		obj.Upload();
		
		scs.clear();
		Account[] accounts = [select Id from Account];
		for(Account acc: accounts){
			scs.add(acc.Id);
		}
		obj.setSelectedResources(scs);
		obj.ResourceName = 'SControls';
		obj.Upload();
			
	}
}